import heapq

a = [34, 25, 12, 99, 87, 63, 58, 78, 88, 92]
print("max: ", heapq.nlargest(1, a))
print("min: ", heapq.nsmallest(1, a))

print("largest: ", heapq.nlargest(3, a))
print("smallest: ", heapq.nsmallest(3, a))

""" 结果
max:  [99]
min:  [12]

largest:  [99, 92, 88]
smallest:  [12, 25, 34]
"""


def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]
b= heapsort(a)
print(b)

""" 结果
[12, 25, 34, 58, 63, 78, 87, 88, 92, 99]
"""